﻿// -----------------------------------------------------------------------
// <copyright file="BlackBoxManagerTest.cs" company="YUMMO">
// Copyright (c) 2013 Lambert van Lieshout, YUMMO Software Development
// </copyright>
// -----------------------------------------------------------------------

namespace Yummo.BlackBox.Test
{
    using System;
    using Xunit;

    public class LogTest
    {
        [Fact]
        public void WriteLogTest()
        {
            // Set up the log manager.
            BlackBoxManager log = new BlackBoxManager();

            // Set up a mockup event writer.
            EventMockWriter writer = new EventMockWriter();

            // Register mockup writer.
            log.RegisterWriter(BlackBoxUtilities.GetAllEventTypes(), writer.Write);

            // Register on static log instance
            Log.SetManager(log);

            // Write event.
            Log.Critical("Hello Critical!");
            Log.Debug("Hello Debug!");
            Log.Error("Hello Error!");
            Log.Error(new ArgumentNullException("name", "Name cannot be NULL"));
            Log.Trace("Hello Trace!");

            // Check if the event is written.
            Assert.Equal<int>(5, writer.EventMessages.Count);
        }
    }
}
